/**
 * output package name
 */
package com.kingdee.eas.custom.bscc.report.client;

import java.awt.event.ActionEvent;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Set;

import javax.swing.event.ChangeEvent;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.eas.basedata.org.CompanyOrgUnitCollection;
import com.kingdee.eas.basedata.org.client.f7.NewCompanyF7;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.fm.common.AccessHelper;
import com.kingdee.eas.fm.common.client.FMClientHelper;
import com.kingdee.eas.fm.common.client.FMClientVerifyHelper;
import com.kingdee.eas.fm.fs.InAcctFactory;
import com.kingdee.eas.fm.fs.client.FSClientHelper;
import com.kingdee.eas.fm.fs.client.SubsidiaryLedgerFilterParam;
import com.kingdee.eas.util.SysUtil;
import com.kingdee.eas.util.client.EASResource;
import com.kingdee.eas.util.client.MsgBox;

/**
 * output class name
 */
public class SubsidiaryLedgerFilterUI extends AbstractSubsidiaryLedgerFilterUI
{
    private static final Logger logger = CoreUIObject.getLogger(SubsidiaryLedgerFilterUI.class);
    
    public SubsidiaryLedgerFilterUI()
    throws Exception
{









/*  41*/        coll = null;
}
protected void chkDispUnUsed_actionPerformed(ActionEvent e)
    throws Exception
{



/*  49*/        super.chkDispUnUsed_actionPerformed(e);
}
protected NewCompanyF7 getNewCompanyF7()
{
/*  53*/        if(FSClientHelper.isCHUser())

/*  55*/            try
        {
/* <-MISALIGNED-> */ /*  55*/                return super.getAllCompanyOrg();
        }
/* <-MISALIGNED-> */ /*  56*/            catch(Exception e)
        {
/* <-MISALIGNED-> */ /*  57*/                handUIException(e);
        }
/* <-MISALIGNED-> */ /*  60*/        return super.getNewCompanyF7();
}
public Object getParam()
{
/*  67*/        SubsidiaryLedgerFilterParam para = new SubsidiaryLedgerFilterParam();
/*  68*/        String companyIds[] = getCompanyIds();
/*  69*/        para.setCompanyIds(companyIds);
/*  70*/        para.setByDay(rdbByDate.isSelected());
/*  71*/        para.setBeginMonth(AccessHelper.getSpiValue(spiMonthFrom));
/*  72*/        para.setBeginYear(AccessHelper.getSpiValue(spiYearFrom));
/*  73*/        para.setEndMonth(AccessHelper.getSpiValue(spiMonthTo));
/*  74*/        para.setEndYear(AccessHelper.getSpiValue(spiYearTo));
//
/*  76*/        para.setToDate(dtpDateTo.getSqlDate());
/*  77*/        para.setFromDate(dtpDateFrom.getSqlDate());
//
//
//
/*  81*/        para.setDispBalance(chkDispBalance.isSelected());
/*  82*/        para.setDispUnUsed(chkDispUnUsed.isSelected());
/*  83*/        para.setDispYearTotal(chkDispYearTotal.isSelected());
/*  84*/        para.setDispMouthTotal(chkDispMouthTotal.isSelected());
/*  85*/        para.setDisDayTotal(chkDispDayTotal.isSelected());
/*  86*/        para.setOrderByCompany(rdbByCompany.isSelected());

/*  88*/        return para;
}
public void setParam(Object param)
{
/*  92*/        if(param == null)
    {/*  93*/            return;
    } else
    {/*  95*/            SubsidiaryLedgerFilterParam filterParam = (SubsidiaryLedgerFilterParam)param;
/*  96*/            String companyIds[] = filterParam.getCompanyIds();

















/* 114*/            setCompanyIds(companyIds);
/* 115*/            rdbByDate.setSelected(filterParam.isByDay());
/* 116*/            rdbByMonth.setSelected(!filterParam.isByDay());
/* 117*/            spiYearFrom.setValue(new Integer(filterParam.getBeginYear()));
/* 118*/            spiYearTo.setValue(new Integer(filterParam.getEndYear()));
/* 119*/            spiMonthFrom.setValue(new Integer(filterParam.getBeginMonth()));
/* 120*/            spiMonthTo.setValue(new Integer(filterParam.getEndMonth()));
/* 121*/            dtpDateTo.setValue(filterParam.getToDate());
/* 122*/            dtpDateFrom.setValue(filterParam.getFromDate());


/* 125*/            chkDispBalance.setSelected(filterParam.isDispBalance());
/* 126*/            chkDispUnUsed.setSelected(filterParam.isDispUnUsed());
/* 127*/            chkDispYearTotal.setSelected(filterParam.isDispYearTotal());
/* 128*/            chkDispMouthTotal.setSelected(filterParam.isDispMouthTotal());
/* 129*/            chkDispDayTotal.setSelected(filterParam.isDisDayTotal());
/* 130*/            rdbByCompany.setSelected(filterParam.isOrderByCompany());
/* 131*/            rdbByType.setSelected(!filterParam.isOrderByCompany());

/* 133*/            return;
//    }
}
protected void rdbByMonth_stateChanged(ChangeEvent e)
    throws Exception
{
/* <-MISALIGNED-> */ /* 136*/        palDate.setVisible(false);
/* <-MISALIGNED-> */ /* 137*/        palMonth.setVisible(false);
/* <-MISALIGNED-> */ /* 138*/        if(rdbByMonth.isSelected())
    {
/* <-MISALIGNED-> */ /* 139*/            palMonth.setVisible(true);
    } else
    {
/* <-MISALIGNED-> */ /* 141*/            palDate.setVisible(true);
/* <-MISALIGNED-> */ /* 143*/            if(dtpDateFrom.getValue() == null && dtpDateTo.getValue() == null)
        {
/* <-MISALIGNED-> */ /* 144*/                Calendar date = Calendar.getInstance();
/* <-MISALIGNED-> */ /* 145*/                dtpDateFrom.setValue(date.getTime());
/* <-MISALIGNED-> */ /* 146*/                dtpDateTo.setValue(date.getTime());
        }
    }
}
protected void init()
    throws Exception
{
/* <-MISALIGNED-> */ /* 154*/        super.init();
}
public boolean verify()
{















/* 177*/        if(getCompanyIds() == null || getCompanyIds().length == 0)
    {/* 178*/            btnCompanySelect.requestFocus(true);
/* 179*/            MsgBox.showWarning(this, EASResource.getString("com.kingdee.eas.fm.fs.FSClientResource", "NoOrgUnit"));

/* 181*/            SysUtil.abort();
    }




/* 187*/        if(rdbByMonth.isSelected())
    {/* 188*/            if(AccessHelper.getSpiValue(spiYearFrom) * 12 + AccessHelper.getSpiValue(spiMonthFrom) > AccessHelper.getSpiValue(spiYearTo) * 12 + AccessHelper.getSpiValue(spiMonthTo))
        {



/* 193*/                spiYearFrom.requestFocus(true);
/* 194*/                MsgBox.showWarning(this, EASResource.getString("com.kingdee.eas.fm.fs.FSClientResource", "CheckDateFromTo"));

/* 196*/                SysUtil.abort();
        }
    } else
    {/* 199*/            FMClientVerifyHelper.verifyEmpty(this, "com.kingdee.eas.fm.fs.FSClientResource", dtpDateTo, "NoDate");

/* 201*/            FMClientVerifyHelper.verifyEmpty(this, "com.kingdee.eas.fm.fs.FSClientResource", dtpDateFrom, "NoDate");

/* 203*/            if(dtpDateTo.getSqlDate().before(dtpDateFrom.getSqlDate()))
        {/* 204*/                dtpDateFrom.requestFocus(true);
/* 205*/                MsgBox.showWarning(this, EASResource.getString("com.kingdee.eas.fm.fs.FSClientResource", "CheckDateFromTo"));

/* 207*/                SysUtil.abort();
        }
    }




/* 214*/        try
    {
/* <-MISALIGNED-> */ /* 214*/            java.util.Date fsUsedDate = FSClientHelper.getClearingHouse().getOpenDate();
/* <-MISALIGNED-> */ /* 215*/            Calendar cal = Calendar.getInstance();

/* 219*/            if(rdbByMonth.isSelected())
/* 220*/                cal.set(AccessHelper.getSpiValue(spiYearFrom), AccessHelper.getSpiValue(spiMonthFrom), 0, 0, 0);


/* 223*/            else/* 223*/                cal.setTime(dtpDateFrom.getSqlDate());


/* 226*/            if(cal.getTime().before(fsUsedDate))
        {/* 227*/                spiYearFrom.requestFocus(true);
/* 228*/                MsgBox.showWarning(this, EASResource.getString("com.kingdee.eas.fm.fs.FSClientResource", "CheckBeginDate"));


/* 231*/                SysUtil.abort();
        }
    }/* 233*/        catch(EASBizException e)
    {/* 234*/            handUIException(e);
    }/* 235*/        catch(BOSException e)
    {/* 236*/            handUIException(e);
    }

/* 239*/        return true;
}
protected void initCompanyState()
{







/* 250*/        super.initCompanyState();
/* 251*/        if(FSClientHelper.isClearingHouseCompanyId(""))
    {/* 252*/            chkIA.setEnabled(true);
/* 253*/            btnCompanySelect.setEnabled(true);
/* 254*/            btnCompanySelect.setVisible(true);
    }
}
protected void companyValueChange(Object object)
    throws Exception
{





/* 265*/        Object array[] = (Object[])(Object[])object;



/* 269*/        super.companyValueChange(((Object) (array)));
}
protected void setDefaultValue()
{

/* 274*/        chkDispUnUsed.setSelected(false);
/* 275*/        rdbByMonth.setSelected(true);
/* 276*/        rdbByCompany.setSelected(true);

/* 278*/        chkDispBalance.setSelected(true);
/* 279*/        chkDispYearTotal.setSelected(true);
/* 280*/        chkDispMouthTotal.setSelected(true);
/* 281*/        chkDispDayTotal.setSelected(true);







/* 289*/        FMClientHelper.initSpinFromTO(spiYearFrom, spiMonthFrom, spiYearTo, spiMonthTo);


/* 292*/        lblMonthFrom.setEnabled(true);
/* 293*/        lblMonthTo.setEnabled(true);
/* 294*/        lblYearFrom.setEnabled(true);
/* 295*/        lblYearTo.setEnabled(true);

/* 297*/        if(coll == null)

/* 299*/            try
        {
/* <-MISALIGNED-> */ /* 299*/                coll = InAcctFactory.getRemoteInstance().getInAcctApplyCompany();
        }
/* <-MISALIGNED-> */ /* 300*/            catch(BOSException e)
        {
/* <-MISALIGNED-> */ /* 301*/                handUIException(e);
        }
/* <-MISALIGNED-> */ /* 302*/            catch(EASBizException e)
        {
/* <-MISALIGNED-> */ /* 303*/                handUIException(e);
                                 
        }
                      Set set=new HashSet();
                      set.add("/9+hztooR22KZY1mjvV3aMznrtQ=");
/* <-MISALIGNED-> */ /* 306*/        setCompanyIdSet(set);
}
protected Class getParamClass()
{

/* 316*/        return com.kingdee.eas.fm.fs.client.SubsidiaryLedgerFilterParam.class;
}
public static final String resourcePath = "com.kingdee.eas.fm.fs.FSClientResource";
CompanyOrgUnitCollection coll;

}